package com.zky.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.zky.DAO.impl.OrderDaoImpl;
import com.zky.biz.Constant;
import com.zky.biz.Email;
import com.zky.biz.JavaMailTool;
import com.zky.entity.Orderss;

public class OrderAction extends OrderDaoImpl{
	
	private Orderss order;
	
	
	public Orderss getOrder() {
		return order;
	}


	public void setOrder(Orderss order) {
		this.order = order;
	}
	
	
	
	
	public String sendOrder(){
		this.doOrder(order);
		Email email = new Email();
		String text = order.getOrderMsg()+"\n总金额："+order.getAmount()+"\n发货地址："+order.getAddress(); 
		email.setSmtpServSrc("smtp."+Constant.EMAIL_ADDRESS.substring(Constant.EMAIL_ADDRESS.indexOf("@")+1));
		email.setAddressSrc(Constant.EMAIL_ADDRESS);
		email.setAddressStd(order.getEmail());
		email.setUsernameSrc(Constant.EMAIL_USERNAME);
		email.setPasswordSrc(Constant.EMAIL_PASSWORD);
		email.setTitle("购物提醒");
		email.setContent(text);
		JavaMailTool.appacheSimpleSend(email);
		HttpServletRequest request = ServletActionContext.getRequest(); 
		HttpSession s = request.getSession();
		s.removeAttribute("kk");
		return "success";
		
		
	}


	
	
	
	
	
	
	
	
	
	

}
